package com.hooya.fa.eu.biz.controller;

import com.hooya.fa.eu.api.vo.ProfitInfoVO;
import com.hooya.fa.eu.biz.service.ProfitService;
import com.hooya.integrated.common.core.util.R;
import com.hooya.integrated.common.security.annotation.Inner;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description 利润检查
 * @Author : Zongz
 * @Copyright Copyright (c) 豪雅集团
 * @Create 2024/12/10
 * @Version 1.1.0
 */
@RestController
@RequiredArgsConstructor
@Tag(name = "利润检查")
@RequestMapping("/profit")
public class ProfitController {

    private final ProfitService profitService;


    @Inner(value = false)
    @PostMapping("/init")
    @Operation(summary = "库存记录初始化【√】", hidden = true, description = "根据库存记录某一日的日期初始化利润检查（所有）数据")
    public R initProfitByKcjl(@RequestParam("date") String date) {
        profitService.initProfitByKcjl(date);
        return R.ok();
    }

    @Inner(value = false)
    @GetMapping("/export")
    @ResponseExcel(name = "#date + '_' + #belongs + '_profit'")
    @Operation(summary = "导出利润检查表【√】", hidden = true, description = "根据日期导出相关货权利润检查数据")
    public List<ProfitInfoVO> exportProfitReport(@RequestParam("date") String date, @RequestParam("belongs") String belongs) {
        return profitService.exportProfitReport(date, belongs);
    }

    @Inner(value = false)
    @PostMapping("/even/up")
    @Operation(summary = "利润检查表与理论库存平仓【√】", hidden = true, description = "根据日期将利润检查表与理论库存平仓，得出盘库数据")
    public R profitEvenUp(@RequestParam("date") String date) {
        profitService.profitEvenUp(date);
        return R.ok();
    }

    @Inner(value = false)
    @PostMapping("/supplement")
    @Operation(summary = "补充profitEvenUp缺失得数量【√】", hidden = true,
            description = "补充遗漏逻辑。需要对profitEvenUp后，其中销售缺失的数量的补齐")
    public R genDiffKc(@RequestParam("beforeDate") String beforeDate, @RequestParam("afterDate") String afterDate) {
        profitService.genDiffKc(beforeDate, afterDate);
        return R.ok();
    }

}
